home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / ML_BME1.ZIP / ROTATE / V4 / ROTASM4.ASM < prev    next >
Encoding:
Assembly Source File  |  1996-11-30  |  5.6 KB  |  200 lines

  1. ; Bitmap rotation engine, v4.0
  2. ; by Maple Leaf, 28 Oct 96
  3. ;
  4. ; This version deals with 256x256 bitmaps !
  5. ; --------------------------------------------------------------------------
  6. ; It is an improved(?) version of ROTASM3. MUCH bigger. Not much faster.
  7. ; --------------------------------------------------------------------------
  8. ; asm rules, yup yup! the others suck!
  9.  
  10. .model TPascal
  11. .386
  12. .DATA
  13.  
  14.         extrn    _Ax_ : WORD
  15.         extrn    _Ay_ : WORD
  16.         extrn    _Bx_ : WORD
  17.         extrn    _By_ : WORD
  18.         extrn    _Cx_ : WORD
  19.         extrn    _Cy_ : WORD
  20.         extrn    vScr:WORD
  21.         extrn    Img:DWORD
  22.         extrn    Angle:BYTE
  23.         extrn    WW:WORD
  24.         extrn    WH:WORD
  25.         extrn    CosTab:BYTE
  26.         extrn    SinTab:BYTE
  27.  
  28. .CODE
  29.  
  30.         public   GenFrame
  31.  
  32. include jumps.inc
  33.  
  34. ;****************************************************************************
  35.  
  36. proc    ComputeFramePara near
  37.  
  38.         movzx    ax,Angle
  39.         mov      si,ax
  40.         add      al,64     ; Angle+90 in a 360-deg system
  41.         mov      di,ax
  42.  
  43.         add      si,si
  44.         add      di,di     ; indexes in SinTab/CosTab
  45.  
  46.         mov      ax,WH
  47.         xor      dx,dx
  48.         mov      cx,word ptr CosTab[si]
  49.         imul     cx
  50.         shrd     ax,dx,8
  51.         add      ax,_Ax_   ; ax = _ax_ + WH * cos (angle)
  52.         mov      _Bx_,ax   ; store result
  53.  
  54.         mov      ax,WH
  55.         xor      dx,dx
  56.         mov      cx,word ptr SinTab[si]
  57.         imul     cx
  58.         shrd     ax,dx,8
  59.         sub      ax,_Ay_
  60.         neg      ax       ; ax = _ay_ - WH * sin (angle)
  61.         mov      _By_,ax  ; store result
  62.  
  63.         mov      ax,WW
  64.         xor      dx,dx
  65.         mov      cx,word ptr CosTab[di]
  66.         imul     cx
  67.         shrd     ax,dx,8
  68.         add      ax,_Ax_  ; ax = _ax_ + WW * cos (angle+90)
  69.         mov      _Cx_,ax  ; store result
  70.  
  71.         mov      ax,WW
  72.         xor      dx,dx
  73.         mov      cx,word ptr SinTab[di]
  74.         imul     cx
  75.         shrd     ax,dx,8
  76.         sub      ax,_Ay_
  77.         neg      ax       ; eax = _ay_ - WW * sin (angle+90)
  78.         mov      _Cy_,ax  ; store result
  79.  
  80.         ;
  81.  
  82.         mov      ax,_Cx_
  83.         sub      ax,_Ax_
  84.         cwd
  85.         mov      dh,dl   ;
  86.         mov      dl,ah   ; shld dx,ax,8
  87.         mov      ah,al   ;
  88.         mov      al,0    ; shl ax,8
  89.         mov      cx,320
  90.         idiv     cx      ; hAdvX = ((_cx_-_ax_) shl 8) div 320
  91.         mov      byte ptr cs:smc5+1,al  ; SMCODE INIT
  92.         mov      byte ptr cs:smc6+1,ah  ; SMCODE INIT
  93.  
  94.         mov      ax,_Cy_
  95.         sub      ax,_Ay_
  96.         cwd
  97.         mov      dh,dl   ;
  98.         mov      dl,ah   ; shld dx,ax,8
  99.         mov      ah,al   ;
  100.         mov      al,0    ; shl ax,8
  101.         mov      cx,320
  102.         idiv     cx      ; hAdvY = ((_cy_-_ay_) shl 16) div 320
  103.         mov      byte ptr cs:smc5+2,al  ; SMCODE INIT
  104.         mov      byte ptr cs:smc7+1,ah  ; SMCODE INIT
  105.  
  106.         mov      ax,_Bx_
  107.         sub      ax,_Ax_
  108.         cwd
  109.         mov      dh,dl   ;
  110.         mov      dl,ah   ; shld dx,ax,8
  111.         mov      ah,al   ;
  112.         mov      al,0    ; shl ax,8
  113.         mov      cx,200
  114.         idiv     cx      ; vAdvX = ((_bx_-_ax_) shl 16) div 200
  115.         mov      word ptr cs:smc3+1,ax  ; SMCODE INIT
  116.  
  117.         mov      ax,_By_
  118.         sub      ax,_Ay_
  119.         cwd
  120.         mov      dh,dl   ;
  121.         mov      dl,ah   ; shld dx,ax,8
  122.         mov      ah,al   ;
  123.         mov      al,0    ; shl ax,8
  124.         mov      cx,200
  125.         idiv     cx      ; vAdvY = ((_by_-_ay_) shl 16) div 200
  126.         mov      word ptr cs:smc4+2,ax  ; SMCODE INIT
  127.  
  128.         retn
  129.         endp
  130.  
  131. ;****************************************************************************
  132.  
  133. GenFrame PROC    NEAR
  134.  
  135.         push     ds es si
  136.  
  137. ;       pusha    ; in my example I don't need such sober instructions... :)
  138.                  ; but if the registers are vital to your application, feel
  139.                  ; free to erase the comment (see POPA, too!)
  140.  
  141.         call     ComputeFramePara
  142.  
  143.         mov      es,vScr
  144.         xor      di,di
  145.  
  146.         mov      ah,byte ptr _Ax_    ;  starting coordinates
  147.         mov      dh,byte ptr _Ay_    ;
  148.  
  149.         mov      al,0
  150.         mov      dl,al
  151.  
  152.         mov      ds,Img[2]  ; bitmap seg (from this point on)
  153.  
  154. ;-- Loop 1 (200 times) ------------------------------------------------------
  155.         mov      cx,200
  156.  
  157. Loop1:   push     ax cx dx
  158.  
  159. ;-- Loop 2 (320 times) ------------------------------------------------------
  160.  
  161.          mov       bl,ah
  162.          mov       bh,dh  ; init coords/offset
  163.  
  164. smc5:    mov       cx,1234h   ; LohAdvY*256+LohAdvX
  165. smc6:    mov       ah,12h     ; HihAdvX
  166. smc7:    mov       dh,12h     ; HihAdvY
  167.  
  168.         rept 320              ;
  169.          mov      si,bx       ;
  170.                               ;  I don't know how to make the "loop"
  171.          add      al,cl       ;  faster than this...
  172.          adc      bl,ah       ;  This will generate a "huge" code (3520 bytes)
  173.          movsb
  174.          add      dl,ch       ;  and I really don't know whether it is
  175.          adc      bh,dh       ;  a useful trick in this case, or not.
  176.         endm                  ;
  177.  
  178. ;-- End loop 2 --------------------------------------------------------------
  179.  
  180.         pop      dx cx ax
  181.  
  182. smc3:   add      ax,1234h ;vAdvX
  183. smc4:   add      dx,1234h ;vAdvY
  184.  
  185.         dec      cl
  186.         jnz      Loop1
  187.  
  188. ;-- End loop 1---------------------------------------------------------------
  189.  
  190. ;       popa
  191.  
  192.         pop      si es ds
  193.  
  194.         retn
  195.  
  196.         endp
  197.  
  198.  
  199.         END
  200.